﻿using PetaPoco;
using System;
using System.ComponentModel.DataAnnotations;

namespace Cxuu.Models
{

    [TableName("cxuu_article")]
    [PrimaryKey("Id", AutoIncrement = true)]
    public class Article
    {
        public int Id { get; set; }
        public int Cid { get; set; }
        public string Title { get; set; }
        public string Attments { get; set; }
        public string Examine { get; set; }
        public string Img { get; set; }
        public int Imgbl { get; set; }
        public DateTime Time { get; set; }
        public int Hits { get; set; }
        public int Uid { get; set; }
        public int Gid { get; set; }
        public int Status { get; set; }
        public int AttA { get; set; }
        public int AttB { get; set; }
        public int AttC { get; set; }

    }


    public class EditArticleAndContent
    {
        public int Id { get; set; }
        [Display(Name = "栏目")]
        [Required(ErrorMessage = "请选择栏目")]
        public int Cid { get; set; }
        [Display(Name = "标题")]
        [Required(ErrorMessage = "标题未填写")]
        public string Title { get; set; }
        public string Attments { get; set; }
        [Display(Name = "作者")]
        [Required(ErrorMessage = "作者未填写")]
        public string Examine { get; set; }
        [Display(Name = "缩略图")]
        public string Img { get; set; }
        public DateTime Time { get; set; } = DateTime.Now;
        [Display(Name = "显示状态")]
        [Required(ErrorMessage = "选择内容显示状态")]
        public int Status { get; set; }
        [Display(Name = "头条")]
        public int AttA { get; set; }
        [Display(Name = "小头条")]
        public int AttB { get; set; }
        [Display(Name = "轮换")]
        public int AttC { get; set; }

        public int Aid { get; set; }
        [Display(Name = "内容")]
        [Required(ErrorMessage = "内容未填写")]
        public string Content { get; set; }
        public Article AsArticle()
        {
            return new Article { Id = Id, Cid = Cid, Title = Title, Attments = Attments, Examine = Examine, Img = Img, Time = Time, Status = Status, AttA = AttA, AttB = AttB, AttC = AttC };
        }

        public ArticleContent AsArticleContent()
        {
            return new ArticleContent { Aid = Id, Content = Content };
        }
    }


    public class ViewArticleAndContent
    {
        public int Id { get; set; }
        public int Cid { get; set; }
        public string Title { get; set; }
        public string Attments { get; set; }
        public string Img { get; set; }
        public string Examine { get; set; }
        public int Hits { get; set; }
        public DateTime Time { get; set; }
        public int Aid { get; set; }
        public string Content { get; set; }

    }


    public class ListTag
    {
        public string Key { get; set; }
        public string Value { get; set; }

    }
}


